package com.liuhouse1.config;

import com.liuhouse1.filter.MyFilter;
import com.liuhouse1.servlet.MyServlet;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.boot.web.servlet.ServletRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 *
 */
@Configuration
public class SystemConfig {

    //注册Servlet
    @Bean
    public ServletRegistrationBean servletRegistrationBean(){
        ServletRegistrationBean reg = new ServletRegistrationBean(new MyServlet() , "/loginServlet");
        return reg;
    }


    //注册Filter
    @Bean
    public FilterRegistrationBean filterRegistrationBean(){
        FilterRegistrationBean reg = new FilterRegistrationBean();
        //使用哪个过滤器
        reg.setFilter(new MyFilter());
        //添加过滤器的地址
        reg.addUrlPatterns("/fuser/*");
        return reg;
    }


}
